package com.lovo.dao;

import com.lovo.bean.User;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface UserMapper {
    @Select("select * from t_user")
    @ResultMap("com.lovo.mapper.UserMapper.BaseResultMap")
    List<User> selectAll();

    @Insert("insert into t_user(user_name,user_pwd,user_tel,user_email) values(#{userName},#{userPwd},#{userTel},#{userEmail})")
    int addUser(User user);

    @Update("update t_user set user_name = #{userName},user_pwd = #{userPwd},user_tel = #{userTel},user_email = #{userEmail} where user_id = #{userId}")
    int updateUser(User user);

    @Delete("delete from t_user where user_id = #{id}")
    int deleteUser(@Param("id") int parseInt);

    @SelectProvider(type = com.lovo.provider.UserProvider.class ,method = "selectByQueryProvider")
    @ResultMap("com.lovo.mapper.UserMapper.BaseResultMap")
    List<User> selectByquery(Map<String,Object> map);

    @SelectProvider(type = com.lovo.provider.UserProvider.class ,method = "login")
    @ResultType(com.lovo.bean.User.class)
    User login(Map<String, Object> map);

    @Select("select * from t_user where user_id = #{id}")
    @ResultType(com.lovo.bean.User.class)
    User selectByPrimaryId(@Param("id") int userId);
}